package org.papervision3d.core.proto
{
    import org.papervision3d.core.geom.*;
    import org.papervision3d.objects.DisplayObject3D;

    public class FindCallback extends TraverseCallback
    {
        protected var curpath:Array = new Array();

        public var object:DisplayObject3D = null;
        public var tri:DrawTriangle = null;
        public var face3d:Face3D = null;
        public var path:Array = null;

        public function FindCallback()
        {   
        }

        public override function enter(node:DisplayObject3D):Boolean
        {
            if( node.enabled )curpath.push(node);
            return node.enabled;
        }

        public override function leave(node:DisplayObject3D):void
        {
            curpath.pop();
        }

        protected function found(triangle:DrawTriangle, face3d : Face3D, object:DisplayObject3D):void
        {
            this.tri = triangle;
            this.face3d = face3d;
            this.object = object;
            this.path = (new Array()).concat(curpath);
        }

    }
}
